//HJ73
#include <iostream>
using namespace std;

int main() {
    int _year, _month, _day;
    int n, i;
    int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    while (cin >> _year >> _month >> _day) { // 注意 while 处理多个 case
        n = 0;
        for (i = 1; i < _month; i++)
            n += a[i];
        if (_month > 2 && (_year % 4 == 0 && _year % 100 != 0 || _year % 400 == 0))
            n += 1;
        n += _day;
        cout << n << endl;
    }
    return 0;
}
